<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('案源委托列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>管理编码：</label>
                                <input type="text" name="managementCode"/>
                            </li>

                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.addFull()" shiro:hasPermission="business:entrustment:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.editFull()" shiro:hasPermission="business:entrustment:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="business:entrustment:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="business:entrustment:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var listFlag = [[${@permission.hasPermi('business:entrustment:list')}]];

        var editFlag = [[${@permission.hasPermi('business:entrustment:edit')}]];
        var removeFlag = [[${@permission.hasPermi('business:entrustment:remove')}]];
        var approvalStatusDatas = [[${@dict.getType('approval_status')}]];
        var payStatusDatas = [[${@dict.getType('pay_status')}]];
        var prefix = ctx + "business/entrustment";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "案源委托",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'entrustId',
                    title: '案源委托id',
                    visible: false
                },
                {
                    field: 'subjectMatter',
                    title: '事由',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value, 5, "open");
                    }
                },
                {
                    field: 'litigationContent',
                    title: '诉讼内容',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value, 5, "open");
                    }
                },
                {
                    field: 'endCriteria',
                    title: '结束标准'
                },
                {
                    field: 'implementationArea',
                    title: '执行地区'
                },
                {
                    field: 'agencyPrice',
                    title: '代理价格'
                },
                {
                    field: 'effectiveTime',
                    title: '有效时间'
                },
                {
                    field: 'managementCode',
                    title: '管理编码'
                },
                {
                    field: 'detailedDescription',
                    title: '详细描述',
                    formatter: function(value, row, index) {
                        return $.table.tooltip(value, 5, "open");
                    }
                },
                {
                    field: 'approvalStatus',
                    title: '审批状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(approvalStatusDatas, value);
                    }
                },
                {
                    field: 'rejectionReasons',
                    title: '驳回原因',
                    visible: false
                },
                {
                    field: 'approvalTime',
                    title: '审批时间'
                },
                {
                    field: 'approver',
                    title: '审批人',
                    visible: false
                },
                {
                    field: 'payStatus',
                    title: '支付状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(payStatusDatas, value);
                    }
                },
                {
                    field: 'payAmount',
                    title: '支付金额',
                    visible: false
                },
                {
                    field: 'payTime',
                    title: '支付时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + listFlag + '" href="javascript:void(0)" onclick="audit(\'' + row.entrustId + '\')"><i class="fa fa-edit"></i>审核</a> ');

                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.editFull(\'' + row.entrustId + '\')"><i class="fa fa-edit"></i>修改</a> ');

                        actions.push('<a class="btn btn-success btn-xs ' + listFlag + '" href="javascript:void(0)" onclick="info(\'' + row.entrustId + '\')"><i class="fa fa-edit"></i>详情</a> ');

                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.entrustId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function audit(entrustId) {
            var url = prefix + '/audit/' + entrustId;
            $.modal.openFull("审批", url);
        }
        function info(entrustId) {
            var url = prefix + '/info/' + entrustId;
            $.modal.openFull("详情", url);
        }
    </script>
</body>
</html>